package api

import (
	"github.com/gin-gonic/gin"
	"net/http"
	es "zg4week2/ess"
	"zg4week2/model/mysql"
	"zg4week2/rouquest"
)

func Health(c *gin.Context) {
	var App rouquest.Video
	if err := c.ShouldBindJSON(&App); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"err": "error"})
		return
	}
	stu := es.EsVideo(App.VideoTitle)
	c.JSON(http.StatusOK, gin.H{"code": "200", "msg": "查询成功", "data": stu})
}
func VideoAdd(c *gin.Context) {
	var App rouquest.VideoAdd
	if err := c.ShouldBindJSON(&App); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"err": "error"})
		return
	}
	stu := mysql.Video{
		VideoTitle:   App.VideoTitle,
		VideoName:    App.VideoName,
		VideoAddress: App.VideoAddress,
		VideoSort:    App.VideoSort,
		VideoPro:     App.VideoPro,
	}
	err := stu.Create()
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{"err": "添加失败"})
		return
	}
	c.JSON(http.StatusOK, gin.H{"msg": "添加成功"})
}
func Video(c *gin.Context) {

}
